home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWResour / Sources / FWLbInit.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  3.3 KB  |  125 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWLbInit.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #ifndef FWCFMRES_H
  13. #include "FWCFMRes.h"
  14. #endif
  15.  
  16. #if defined(SYMANTEC_CPLUS) && defined(FW_BUILD_MAC)
  17.     #define ODFCFMINIT PartCFMInit
  18.     #if !FW_LIB_EXPORT_PRAGMAS
  19.         #pragma internal on
  20.     #endif
  21. #endif
  22.  
  23. //========================================================================================
  24. // Prototypes
  25. //========================================================================================
  26.  
  27. #ifdef FW_BUILD_MAC
  28. extern "C" pascal OSErr ODFCFMINIT (CFragInitBlockPtr initBlkPtr);
  29. extern "C" pascal void  ODFCFMTERM (void);
  30.  
  31. #if GENERATINGPOWERPC
  32.  
  33. #ifdef __MWERKS__
  34. extern "C" void __sinit();
  35. extern "C" void    __destroy_global_chain(void);
  36. #elif defined __MRC__
  37. extern "C" void __CPlusInit();
  38. #endif
  39.  
  40. #endif // GENERATINGPOWERPC
  41.  
  42. #endif // FW_BUILD_MAC
  43.  
  44. //========================================================================================
  45. //    Global Variable
  46. //========================================================================================
  47. //    FW_gInstance is initialized in DLLMain for Windows
  48. //    FW_gInstance is defined in FWCFMRes.cpp for the Mac
  49. #ifdef FW_BUILD_WIN
  50. FW_Instance FW_gInstance = NULL;
  51. #endif
  52.  
  53. //========================================================================================
  54. // Initialization methods
  55. //========================================================================================
  56.  
  57. #ifdef FW_BUILD_WIN32
  58. //----------------------------------------------------------------------------------------
  59. // DllMain
  60. //----------------------------------------------------------------------------------------
  61. extern "C" BOOL WINAPI DllMain(HINSTANCE    hDLL,
  62.                     DWORD        dwReason,
  63.                     LPVOID        /* lpReserved */)
  64. {
  65.     if(dwReason == DLL_PROCESS_ATTACH)
  66.     {
  67.         // Save instance handle for future use
  68.         FW_gInstance = hDLL;
  69.     }
  70.  
  71.     return TRUE;
  72. }
  73. #endif
  74.  
  75. #ifdef FW_BUILD_MAC
  76. //----------------------------------------------------------------------------------------
  77. // ODFCFMINIT
  78. //----------------------------------------------------------------------------------------
  79. // Has to be upper case because of the 68K Linker
  80.  
  81. extern "C" pascal OSErr ODFCFMINIT(CFragInitBlockPtr initBlkPtr)
  82. {
  83. #ifdef FW_DEBUG
  84.     #define FW_COMMAND 0x37
  85.     
  86.     KeyMap theKeyMap;
  87.     ::GetKeys(theKeyMap);
  88.     const unsigned char *theKeys = (const unsigned char *) theKeyMap;
  89.     if ((theKeys[FW_COMMAND >> 3] >> (FW_COMMAND & 7)) & 1)
  90.         ::DebugStr("\pODFCFMInit");
  91. #endif
  92.  
  93.     // Shared libraries don't get there static objects initialized correctly without
  94.     // calling __sinit or __CPlusInit for MetroWerks or MrC respectively.
  95.  
  96. #if GENERATINGPOWERPC
  97. #ifdef __MWERKS__
  98.     __sinit();
  99. #elif defined __MRC__
  100.     __CPlusInit();
  101. #endif
  102. #endif
  103.     
  104.     OSErr err = InitLibraryResources(initBlkPtr);
  105.  
  106.     return err;
  107. }
  108. #endif
  109.  
  110. #ifdef FW_BUILD_MAC
  111. //----------------------------------------------------------------------------------------
  112. // ODFCFMTERM
  113. //----------------------------------------------------------------------------------------
  114.  
  115. extern "C" pascal void ODFCFMTERM(void)
  116. {
  117. #if GENERATINGPOWERPC
  118. #ifdef __MWERKS__
  119.     __destroy_global_chain();
  120. #endif
  121. #endif
  122. }
  123. #endif
  124.  
  125.